﻿using System;

namespace UniRx.Operators
{
	// Token: 0x0200024C RID: 588
	internal class AsUnitObservableObservable<T> : OperatorObservableBase<Unit>
	{
		// Token: 0x06000D89 RID: 3465 RVA: 0x0004033C File Offset: 0x0003E73C
		public AsUnitObservableObservable(IObservable<T> source) : base(source.IsRequiredSubscribeOnCurrentThread<T>())
		{
			this.source = source;
		}

		// Token: 0x06000D8A RID: 3466 RVA: 0x00040351 File Offset: 0x0003E751
		protected override IDisposable SubscribeCore(IObserver<Unit> observer, IDisposable cancel)
		{
			return this.source.Subscribe(new AsUnitObservableObservable<T>.AsUnitObservable(observer, cancel));
		}

		// Token: 0x040007A9 RID: 1961
		private readonly IObservable<T> source;

		// Token: 0x0200024D RID: 589
		private class AsUnitObservable : OperatorObserverBase<T, Unit>
		{
			// Token: 0x06000D8B RID: 3467 RVA: 0x00040365 File Offset: 0x0003E765
			public AsUnitObservable(IObserver<Unit> observer, IDisposable cancel) : base(observer, cancel)
			{
			}

			// Token: 0x06000D8C RID: 3468 RVA: 0x0004036F File Offset: 0x0003E76F
			public override void OnNext(T value)
			{
				this.observer.OnNext(Unit.Default);
			}

			// Token: 0x06000D8D RID: 3469 RVA: 0x00040384 File Offset: 0x0003E784
			public override void OnError(Exception error)
			{
				try
				{
					this.observer.OnError(error);
				}
				finally
				{
					base.Dispose();
				}
			}

			// Token: 0x06000D8E RID: 3470 RVA: 0x000403BC File Offset: 0x0003E7BC
			public override void OnCompleted()
			{
				try
				{
					this.observer.OnCompleted();
				}
				finally
				{
					base.Dispose();
				}
			}
		}
	}
}
